﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.Processiings_ThreeWay;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Processiings_ThreeWayAllController : ControllerBase
    {
        IMediator mediator;

        public Processiings_ThreeWayAllController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<ApiResult<int>> AddThreeWayAll(Processiings_Three Processiings_Three)
        {
            try
            {
                AddThreeWayCommand AddThreeWayCommand = new AddThreeWayCommand()
                {
                    Processiings_Three = Processiings_Three
                };
                return await mediator.Send(AddThreeWayCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Processiings_Three>> FirstNextSlaughts([FromQuery] FirstThreeWayCommand FirstThreeWayCommand)
        {
            try
            {
                return await mediator.Send(FirstThreeWayCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateNextSlaughts(Processiings_Three Processiings_Three)
        {
            try
            {
                UpdateThreeWayCommand UpdateThreeWayCommand = new UpdateThreeWayCommand()
                {
                    Processiings_Three = Processiings_Three
                };
                return await mediator.Send(UpdateThreeWayCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
